Wishbone python module is installed from wishbone github, development branch (version 0.2.4).
data_tsne_cluster <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_exprs_tsne_cluster.csv", header = TRUE, row.names = 1, check.names = FALSE)
data <- data_tsne_cluster[,1:36]
write.csv(data, file = "./runWishbone/130515_C2_stim_CD19-_exprsData.csv")
import wishbone
import os
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import random
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998719
# 2 0.996607
# 3 0.994859
# 4 0.994749
# 5 0.993862
# 6 0.993038
# 7 0.991455
# 8 0.991046
# 9 0.989743
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_exprs_tsne_cluster.csv')
start_cell = scdata.data.index[cell['ClusterX'] == 11][0] ## Using yd Vd2+ as starting cell
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3], num_waypoints=150)
dfmap = scdata.diffusion_eigenvectors.copy()
dfmap.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_diffusionmap.csv", sep='\t', encoding='utf-8')
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_trajectory.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_branches.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_wanderlust_trajectory.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_branches.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_wanderlust_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
diffMap <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_diffusionmap.csv",
sep = "\t", header = TRUE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_exprs_tsne_cluster.csv",
header = TRUE, row.names = 1, check.names = FALSE)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
data$cluster <- factor(data$ClusterX)
diffMap <- diffMap[,2:4]
colnames(diffMap) <- paste("diffusionmap", 1:3, sep="_")
data <- cbind(data, diffMap)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
dataCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
group = cluster, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
group = branches, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
color = trajectory, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
color = wanderlust, type = "scatter2d", mode = "markers")
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998719
# 2 0.996607
# 3 0.994859
# 4 0.994749
# 5 0.993862
# 6 0.993038
# 7 0.991455
# 8 0.991046
# 9 0.989743
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_exprs_tsne_cluster.csv')
start_cell = scdata.data.index[cell['ClusterX'] == 2][0] ## Using CD4 Naive as starting cell
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3], num_waypoints=150)
dfmap = scdata.diffusion_eigenvectors.copy()
dfmap.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_diffusionmap1.csv", sep='\t', encoding='utf-8')
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_trajectory1.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_branches1.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_exprsData_wanderlust_trajectory1.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_trajectory1.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_wishbone_branches1.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_wanderlust_trajectory1.csv",
sep = "\t", header = FALSE, row.names = 1)
diffMap <- read.csv("./runWishbone/130515_C2_stim_CD19-_exprsData_diffusionmap1.csv",
sep = "\t", header = TRUE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_exprs_tsne_cluster.csv",
header = TRUE, row.names = 1, check.names = FALSE)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
data$cluster <- factor(data$ClusterX)
diffMap <- diffMap[,2:4]
colnames(diffMap) <- paste("diffusionmap", 1:3, sep="_")
data <- cbind(data, diffMap)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
dataCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
group = cluster, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
group = branches, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
color = trajectory, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
color = wanderlust, type = "scatter2d", mode = "markers")
subsample1 <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample1_isomap.csv",
header = TRUE, row.names = 1)
write.csv(subsample1[,1:36], file = "./runWishbone/130515_C2_stim_CD19-_subsample1_isomap_data.csv")
subsample2 <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample2_isomap.csv",
header = TRUE, row.names = 1)
write.csv(subsample2[,1:36], file = "./runWishbone/130515_C2_stim_CD19-_subsample2_isomap_data.csv")
subsample3 <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample3_isomap.csv",
header = TRUE, row.names = 1)
write.csv(subsample3[,1:36], file = "./runWishbone/130515_C2_stim_CD19-_subsample3_isomap_data.csv")
## wishbone analysis using python 3.4
## analysis on 130515_C2_stim_CD19-_subsample1_tsne.csv
import wishbone
import os
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import random
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample1_isomap_data.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998694
# 2 0.996565
# 3 0.994834
# 4 0.994491
# 5 0.993673
# 6 0.993010
# 7 0.990936
# 8 0.989012
# 9 0.987728
#scdata.diffusion_eigenvectors
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample1_isomap.csv')
start_cell = scdata.data.index[cell['cluster'] == 11][0]
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3], num_waypoints=150)
dfmap = scdata.diffusion_eigenvectors.copy()
dfmap.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample1_diffusionmap.csv", sep='\t', encoding='utf-8')
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample1_wishbone_trajectory.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample1_wishbone_branches.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample1_wanderlust_trajectory.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample1_wishbone_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample1_wishbone_branches.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample1_wanderlust_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
diffMap <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample1_diffusionmap.csv",
sep = "\t", header = TRUE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample1_isomap.csv",
header = TRUE, row.names = 1)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
diffMap <- diffMap[,2:4]
colnames(diffMap) <- paste("diffusionmap", 1:3, sep="_")
data <- cbind(data, diffMap)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
data$cluster <- factor(data$cluster)
dataCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
group = cluster, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
group = branches, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
color = trajectory, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
color = wanderlust, type = "scatter3d", mode = "markers")
diffMapCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ cluster, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightyellow", high = "red", midpoint = 0.5) +
geom_text(data=diffMapCentre, label= diffMapCentre$cluster, colour = "black", size = 10)
## wishbone analysis using python 3.4
## analysis on 130515_C2_stim_CD19-_subsample2_tsne.csv
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample2_isomap_data.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998680
# 2 0.998223
# 3 0.996568
# 4 0.994847
# 5 0.994663
# 6 0.993699
# 7 0.992927
# 8 0.991812
# 9 0.991462
#scdata.diffusion_eigenvectors
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample2_isomap.csv')
start_cell = scdata.data.index[cell['cluster'] == 11][0]
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4], num_waypoints=150)
dfmap = scdata.diffusion_eigenvectors.copy()
dfmap.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample2_diffusionmap.csv", sep='\t', encoding='utf-8')
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample2_wishbone_trajectory.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample2_wishbone_branches.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample2_wanderlust_trajectory.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample2_wishbone_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample2_wishbone_branches.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample2_wanderlust_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
diffMap <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample2_diffusionmap.csv",
sep = "\t", header = TRUE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample2_isomap.csv",
header = TRUE, row.names = 1)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
diffMap <- diffMap[,2:4]
colnames(diffMap) <- paste("diffusionmap", 1:3, sep="_")
data <- cbind(data, diffMap)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
data$cluster <- factor(data$cluster)
dataCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
group = cluster, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
group = branches, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
color = trajectory, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
color = wanderlust, type = "scatter3d", mode = "markers")
diffMapCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ cluster, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightyellow", high = "red", midpoint = 0.5) +
geom_text(data=diffMapCentre, label= diffMapCentre$cluster, colour = "black", size = 10)
## wishbone analysis using python 3.4
## analysis on 130515_C2_stim_CD19-_subsample3_tsne.csv
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample3_isomap_data.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998726
# 2 0.996564
# 3 0.995391
# 4 0.994791
# 5 0.993863
# 6 0.992953
# 7 0.992029
# 8 0.990977
# 9 0.990575
#scdata.diffusion_eigenvectors
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample3_isomap.csv')
start_cell = scdata.data.index[cell['cluster'] == 11][0]
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4], num_waypoints=150)
dfmap = scdata.diffusion_eigenvectors.copy()
dfmap.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample3_diffusionmap.csv", sep='\t', encoding='utf-8')
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample3_wishbone_trajectory.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample3_wishbone_branches.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/130515_C2_stim_CD19-_subsample3_wanderlust_trajectory.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample3_wishbone_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample3_wishbone_branches.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample3_wanderlust_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
diffMap <- read.csv("./runWishbone/130515_C2_stim_CD19-_subsample3_diffusionmap.csv",
sep = "\t", header = TRUE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/130515_C2_stim_CD19-_subsample3_isomap.csv",
header = TRUE, row.names = 1)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
diffMap <- diffMap[,2:4]
colnames(diffMap) <- paste("diffusionmap", 1:3, sep="_")
data <- cbind(data, diffMap)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
data$cluster <- factor(data$cluster)
dataCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
group = cluster, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
group = branches, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
color = trajectory, type = "scatter3d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2, z = diffusionmap_3,
color = wanderlust, type = "scatter3d", mode = "markers")
diffMapCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ cluster, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightyellow", high = "red", midpoint = 0.5) +
geom_text(data=diffMapCentre, label= diffMapCentre$cluster, colour = "black", size = 10)
## wishbone analysis using python 3.4
## analysis on diffusion map data
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_dfmap_data.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998452
# 2 0.996404
# 3 0.995176
# 4 0.994784
# 5 0.993387
# 6 0.992741
# 7 0.991526
# 8 0.991045
# 9 0.990486
#scdata.diffusion_eigenvectors
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/subset_downsample_500_diffusionmap_progression.csv')
start_cell = scdata.data.index[cell['sampleCluster'] == 11][0]
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4, 5, 6], num_waypoints=150)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_dfmap_data_wishbone_trajectory.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_dfmap_data_wishbone_branches.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4, 5, 6], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_dfmap_data_wanderlust_trajectory.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/subset_downsample_500_dfmap_data_wishbone_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/subset_downsample_500_dfmap_data_wishbone_branches.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/subset_downsample_500_dfmap_data_wanderlust_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/subset_downsample_500_diffusionmap_progression.csv",
header = TRUE, row.names = 1)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
data$cluster <- factor(data$sampleCluster)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
dataCentre <- aggregate(cbind(diffusionmap_1, diffusionmap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=diffusionmap_1, y=diffusionmap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
group = cluster, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
group = branches, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
color = trajectory, type = "scatter2d", mode = "markers")
plot_ly(data, x = diffusionmap_1, y = diffusionmap_2,
color = wanderlust, type = "scatter2d", mode = "markers")
## wishbone analysis using python 3.4
## analysis on ISOMAP progression data
scdata = wishbone.wb.SCData.from_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_isomap_data.csv", data_type='masscyt', normalize=False)
scdata.run_diffusion_map()
scdata.diffusion_eigenvalues
# 0
# 0 1.000000
# 1 0.998421
# 2 0.996694
# 3 0.995313
# 4 0.994773
# 5 0.993195
# 6 0.993036
# 7 0.992874
# 8 0.991634
# 9 0.991610
#scdata.diffusion_eigenvectors
cell = pd.DataFrame.from_csv('/Users/chenhao/GitProject/cytofkit_data_codes/CD14negCD19negPBMC_dataset/subset_downsample_500_isomap_progression.csv')
start_cell = scdata.data.index[cell['sampleCluster'] == 11][0]
wb = wishbone.wb.Wishbone(scdata)
## run wishbone
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4, 5, 6], num_waypoints=150)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_isomap_data_wishbone_trajectory.csv", sep='\t', encoding='utf-8')
branches = wb.branch.copy()
branches.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_isomap_data_wishbone_branches.csv", sep='\t', encoding='utf-8')
## run wanderlust
wb.run_wishbone(start_cell, components_list=[1, 2, 3, 4, 5, 6], num_waypoints=150, branch = False)
trajectory = wb.trajectory.copy()
trajectory.to_csv("/Users/chenhao/GitProject/cytofkit_data_codes/runWishbone/subset_downsample_500_isomap_data_wanderlust_trajectory.csv", sep='\t', encoding='utf-8')
wishbone_trajectory <- read.csv("./runWishbone/subset_downsample_500_isomap_data_wishbone_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
wishbone_branches <- read.csv("./runWishbone/subset_downsample_500_isomap_data_wishbone_branches.csv",
sep="\t", header = FALSE, row.names = 1)
wanderlust_trajectory <- read.csv("./runWishbone/subset_downsample_500_isomap_data_wanderlust_trajectory.csv",
sep = "\t", header = FALSE, row.names = 1)
data <- read.csv("./CD14negCD19negPBMC_dataset/subset_downsample_500_isomap_progression.csv",
header = TRUE, row.names = 1)
data$trajectory <- wishbone_trajectory[,1]
data$branches <- factor(wishbone_branches[,1])
data$wanderlust <- wanderlust_trajectory[,1]
data$cluster <- factor(data$sampleCluster)
clusterName <- c("CD4 CM", "CD4 Naive", "CD4 Eff", "Less diff gd", "CD4 EM", "CD8 Naive", "MAIT", "CD8 EM", "NK", "Late CD4 Eff", "gd Vd2+", "CD8 Eff", "NK", "gd Vd2-", "NKT")
data$clusterLabel <- clusterName[data$cluster]
dataCentre <- aggregate(cbind(isomap_1, isomap_2) ~ clusterLabel, data, median)
ggplot(data, aes(x=isomap_1, y=isomap_2, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
dataCentre2 <- aggregate(cbind(trajectory, branches) ~ clusterLabel, data, median)
ggplot(data, aes(x=trajectory, y=branches, colour = trajectory)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre2, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
data$wanderlustPath <- factor(1)
dataCentre3 <- aggregate(cbind(wanderlust, wanderlustPath) ~ clusterLabel, data, median)
ggplot(data, aes(x=wanderlust, y=wanderlustPath, colour = wanderlust)) +
geom_point(size = 3) + theme_bw() +
scale_color_gradient2(low="blue", mid = "lightgreen", high = "yellow", midpoint = 0.5) +
geom_text_repel(data=dataCentre3, label= dataCentre$clusterLabel,
colour = "black", size = 3, fontface = 'bold',
segment.color = 'red', segment.size = 0.6,
arrow = arrow(length = unit(0.01, 'npc')), force = 1)
plot_ly(data, x = isomap_1, y = isomap_2,
group = cluster, type = "scatter2d", mode = "markers")
plot_ly(data, x = isomap_1, y = isomap_2,
group = branches, type = "scatter2d", mode = "markers")
plot_ly(data, x = isomap_1, y = isomap_2,
color = trajectory, type = "scatter2d", mode = "markers")
plot_ly(data, x = isomap_1, y = isomap_2,
color = wanderlust, type = "scatter2d", mode = "markers")
sessionInfo()
## R version 3.3.0 (2016-05-03)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X 10.11.5 (El Capitan)
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggrepel_0.5 plotly_3.6.5 ggplot2_2.1.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.5 knitr_1.13 magrittr_1.5 munsell_0.4.3
## [5] colorspace_1.2-6 R6_2.1.2 stringr_1.0.0 httr_1.1.0
## [9] plyr_1.8.4 tools_3.3.0 grid_3.3.0 gtable_0.2.0
## [13] htmltools_0.3.5 assertthat_0.1 yaml_2.1.13 digest_0.6.9
## [17] tibble_1.0 gridExtra_2.2.1 formatR_1.4 tidyr_0.5.0
## [21] viridis_0.3.4 base64enc_0.1-3 htmlwidgets_0.6 evaluate_0.9
## [25] rmarkdown_0.9.6 labeling_0.3 stringi_1.1.1 scales_0.4.0
## [29] jsonlite_0.9.21